package me.ymfs.springboot.guice.service.user;

import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.Scopes;
import com.google.inject.Singleton;
import me.ymfs.springboot.guice.mapper.UserMapper;
import me.ymfs.springboot.guice.service.user.impl.UserServiceImpl;
import org.springframework.context.ApplicationContext;

public class UserModule extends AbstractModule {
    @Override
    protected void configure() {
        bind(UserService.class).to(UserServiceImpl.class).in(Scopes.SINGLETON);
    }

    @Provides
    @Singleton
    public UserMapper userMapper(ApplicationContext context) {
        return context.getBean(UserMapper.class);
    }
}
